import { Player } from './data/player';
import { ChooseCardView } from './view/choose_card_view';
import { EndView } from './view/end_view';
import { InitialView } from './view/initial_view';
import { MainView } from './view/main_view';
import { PutBoomView } from './view/put_boom_view';

export class GameController {
    static instance:GameController;

    static getInstance():GameController
    {
        if(GameController.instance == null){
            GameController.instance = new GameController();
        }
        return GameController.instance;
    }

    private initial_view:InitialView;
    private main_view:MainView;
    private choose_card_view:ChooseCardView;
    private put_boom_view:PutBoomView;
    private end_view:EndView;
    constructor(){
        this.initial_view = new InitialView();
        this.main_view = new MainView();
        this.choose_card_view = new ChooseCardView();
        this.put_boom_view = new PutBoomView();
        this.end_view = new EndView();
    }

    //初始化界面
    OpenInitialView(){
        this.initial_view.Open();
    }

    IsInitialViewOpen():boolean{
        return this.initial_view.IsOpen();
    }

    SetInitialViewLoadPercent(percent:number){
        this.initial_view.SetInitialViewLoadPercent(percent);
    }

    CloseInitialView(){
        this.initial_view.Close();
    }

    //-----------------------------------------------------------
    //主界面
    OpenMianView(){
        this.main_view.Open();
    }

    IsMainViewOpen():boolean{
        return this.main_view.IsOpen();
    }

    UpdateMainView(elapse_time:number){
        if(this.IsMainViewOpen()){
            this.main_view.Update(elapse_time);
        }
    }

    // 神卡选择变化卡界面
    OpenChooseCardView(...args: any[]){
        this.choose_card_view.Open(...args);
    }

     // 放回炸弹界面
    OpenPutBoomView(...args: any[]){
        this.put_boom_view.Open(...args);
    }

    //游戏结算界面
    OpenEndView(...args: any[]){
        this.end_view.Open(...args);
    }
}


